﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;
using Component;

namespace Component
{
    public class Languages :Base
    {
        /// <summary>
        /// public static XPCollection<TextStatic> GetAll()
        /// </summary>
        /// <returns>XPCollection<TextStatic></returns>
        public static XPCollection<TextStatic> GetAll(bool admin)
        {
            XPCollection<TextStatic> _xpTextStatic = new XPCollection<TextStatic>(KetNoiCSDL.session);
            _xpTextStatic.Filter = FilterAll(admin);
            return _xpTextStatic;
        }
        /// <summary>
        /// public static TextStatic GetObjectByid(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static TextStatic GetObjectByid(int id,bool admin)
        {
            XPCollection<TextStatic> _xpTextStatic = new XPCollection<TextStatic>(KetNoiCSDL.session);
            _xpTextStatic.Filter = FilterById(id, admin);
            if (_xpTextStatic.Count > 0)
            {
                return _xpTextStatic[0];
            }
            return null;
        }
        /// <summary>
        /// public static TextStatic SearchByKeyWord(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string SearchByKeyWord(string keyWord)
        {
           
            XPCollection<TextStatic> _xpTextStatic = new XPCollection<TextStatic>(KetNoiCSDL.session);
            _xpTextStatic.Filter = FilterByString(ColumTextStatic._KeyWord,keyWord,true);
            if (_xpTextStatic.Count > 0)
            {
                if(Sessions.LanguageVN==true)
                    return _xpTextStatic[0].VN;
                else
                    return _xpTextStatic[0].EL;
            }
            return "keyWord="+keyWord;
        }  
    }
}
